package video

import (
	"supervideo/app/models"
	"supervideo/app/models/zone"
	"supervideo/pkg/database"
)

type Video struct {
	models.BaseModel

	Title       string  `json:"title"`
	Sort        int8    `json:"sort,omitempty"`
	Status      int8    `json:"status,omitempty"`
	ZoneId      uint64  `json:"zone_id"`
	AsName      string  `json:"asname"`
	Length      int     `json:"length"`
	Grade       float32 `sql:"type:decimal(10,2)"`
	Cover       string
	Description string `json:"description"`
	DoubanUrl   string `json:"douban_url"`

	Zone zone.Zone `json:"zone"`

	models.CommonTimestampsField
}

func (video *Video) Create() {
	database.DB.Create(&video)
}

func (video *Video) Save() (rowAffected int64) {
	result := database.DB.Save(&video)
	return result.RowsAffected
}

func (video *Video) Delete() (rowAffected int64) {
	result := database.DB.Delete(&video)
	return result.RowsAffected
}
